<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function add(num1, num2){
      let numD1 = num1.toString().split('.')[1].length
      let numD2 = num2.toString().split('.')[1].length
      let base = 10 ** Math.max(numD1,numD2)
      let sum = num1*base + num2*base
      return sum / base
    }
    console.log(add(0.1, 0.22346))
  </script>
</body>
</html>